Separate DB almost fixed
[RRRRHHHH_Code] / ruralHouses client / src / gui / listOfOffers.java
index 4651ff8..3674c59 100644 (file)
@@ -6,6 +6,8 @@ import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 import java.util.Enumeration;
 import java.util.Vector;
 
@@ -18,8 +20,12 @@ import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 
+import common.HouseInterface;
+
+import configuration.___IntNames;
 import domain.Offer;
 import domain.Owner;
+import domain.RuralHouse;
 
 public class listOfOffers extends JFrame {
 
@@ -54,8 +60,25 @@ public class listOfOffers extends JFrame {
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
                contentPane.setLayout(null);
-
-               this.offers = this.owner.getAllOffers();
+               this.offers = new Vector<Offer>();
+               HouseInterface hm = null;
+               try {
+                       hm = (HouseInterface) Naming
+                                       .lookup(___IntNames.HouseManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
+               Vector<RuralHouse> Hlist = null;
+               try {
+                       Hlist = hm.getHouses(owner, null, null, 0, 0, 0, 0, 0);
+               } catch (RemoteException e1) {
+                       e1.printStackTrace();
+               }
+               for (RuralHouse rh: Hlist){
+                       for(Offer of : rh.getAllOffers())
+                       this.offers.add(of);
+               }
                JLabel lblNewLabel = new JLabel();
                lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
                lblNewLabel.setBounds(23, 41, 536, 33);
@@ -82,8 +105,6 @@ public class listOfOffers extends JFrame {
                tableModel = new DefaultTableModel(null, new String[] { "Offer #",
                                "FirstDay", "LastDay", "Price" ,"RuralHouse"});
 
-               // Maybe there is a better way to avoid interaction.
-               // table.setEnabled(false);
                table.setModel(tableModel);
                table.addMouseListener( new MouseAdapter(){                     
                        @Override